﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Compiler;

namespace WindowsWorkflow.SequentialActivities
{
	public class PickValidator:CompositeActivityValidator 
	{
		public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
		{
			ValidationErrorCollection errors = base.Validate(manager, obj);

			Pick pick = obj as Pick;
			if (pick.Parent !=null)
			{
				foreach (Activity child in pick.EnabledActivities)
				{
					if (Pick.IsLeader(child))
						return errors;
				}

				errors.Add(new ValidationError("At least one child of Pick must not carry the FollowOf attached property", 200));
				return errors;
			}
			else
			{
				return errors;
			}

			

		}
	}
}
